//
//  XHF_GoingProjectTV.m
//  haojia
//
//  Created by 徐宏飞 on 16/4/15.
//  Copyright © 2016年 徐宏飞. All rights reserved.
//

#import "XHF_GoingProjectTV.h"
#import "XHF_GoingProjectTVC.h"

#import "XHF_AFN.h"

@interface XHF_GoingProjectTV ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) NSMutableArray *arr;
@end

@implementation XHF_GoingProjectTV


+(XHF_GoingProjectTV *)GoingProjectTableView{
    XHF_GoingProjectTV *goingTV = [[XHF_GoingProjectTV alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    
    goingTV.backgroundColor = CLEAR;
    goingTV.dataSource = goingTV;
    goingTV.delegate = goingTV;
    
    [goingTV registerNib:[UINib nibWithNibName:@"XHF_GoingProjectTVC" bundle:nil] forCellReuseIdentifier:@"MineGoingProjectCell"];
    [goingTV getData];
    return goingTV;
}


- (void)getData{
    NSMutableArray *arrat = [NSMutableArray array];
    NSString *str = @"http://mobile.ximalaya.com/mobile/discovery/v1/recommend/editor?device=android&pageId=1&pageSize=20&title=小编推荐";
    
    
    [XHF_AFN geturlStr:str Block:^(NSDictionary *resultX) {
        
        
        NSMutableArray *arr = [resultX objectForKey:@"list"];
        
        for (NSMutableDictionary *dic in arr) {
    
            XHF_textModel *model = [XHF_textModel new];
            model.titleName = [dic objectForKey:@"title"];
            
            [arrat addObject:model];
            //            NSLog(@"%@", str);
        }
        self.arr = arrat;
        [self reloadData];
        //        NSLog(@"%@", resultX);
    }];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
    XHF_GoingProjectTVC *cell = [tableView dequeueReusableCellWithIdentifier:@"MineGoingProjectCell"];
    
    cell.modelg = [self.arr objectAtIndex:indexPath.row];
    
    return cell;
}





@end
